package cn.elead.chaos.security.handle;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import cn.elead.chaos.framework.util.ResponseUtils;
import cn.elead.chaos.framework.web.global.ApiResponse;
import cn.elead.chaos.framework.web.wrapper.ResponseWrapper;

/**
 * 自定义退出处理类 返回成功
 * 
 * @author ruoyi
 */
@Configuration
public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler
{

    /**
     * 退出处理
     * 
     * @return
     */
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
            throws IOException, ServletException  {
        
        ResponseUtils.writeValAsJson(request, new ResponseWrapper(response), ApiResponse.success("退出成功"));
        
    }
}
